<?php

namespace App\Models\College;

use App\Models\BaseModel;
use App\Models\Traits\KfUid;

class CollegeTrainingOrderPlanUserModel extends BaseModel
{
    use KfUid;

    protected $table = 'college_training_order_plan_users';

    protected $fillable = [
        'userId',
        'trainingOrderId',
    ];

    public static function init(array $userIds, int $trainingOrderId)
    {
        $data = collect($userIds)->map(function ($userId) use ($trainingOrderId) {
            return [
                'userId'          => $userId,
                'trainingOrderId' => $trainingOrderId,
            ];
        });

        return (new self)->batchAddData($data);
    }
}
